<?php
		header('Content-Type: application/json; charset=utf-8');
		//header("Content-Type: text/html; charset=UTF-8");
        class Get_sushi extends CI_Controller{
                function __construct()
                {
                        parent::__construct();
                }

	/*********************************dz**********************************/
				public function index(){
				
					$this->load->database();
					/*$this->db->select_max("id");
					$max_id = $this->db->get('context');
					$begin_id=0;
					if ($max_id->num_rows() > 0){
						foreach ($max_id->result() as $row){
					
					*/					
					$this->db->select('id');
					$query = $this->db->get('sushi');
					$rows = $query->num_rows();					
					$begin_id = $_GET['page']*20;
					if($begin_id<$rows){
					
						$this->db->select('id,title,shiwen,shangxi');  
						$this->db->order_by('id','desc');
						if($_GET['page']==0){
							$this->db->limit(20); 
						}else{
							$this->db->limit(20,$begin_id); 
						}
					 
						$query = $this->db->get('sushi');
						if ($query->num_rows() > 0){
							foreach ($query->result() as $row){
								$array = array(
									'id'=>$row->id,
									'title'=>$row->title,
									'shiwen'=>$row->shiwen,
									'shangxi'=>$row->shangxi
								);
								$result[] = $array;
							}
						}
						$this->load->library('array_to_json');
						echo $this->array_to_json->JSON($result);
					}
				}
			}
